{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3079
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	n,ans,p1,p2:int64;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
ans:=0;
p2:=n;
read(n);
p1:=n;
read(n);
while n<>0 do begin
	if (p1>p2) and (p1>n) then inc(ans);
	p2:=p1;
	p1:=n;
	read(n);
end;
write(ans);
end.